/**
* @Title: selfFeedback_service.js
* @Description: TODO
* Copyright: Copyright (c) 2014 
 * Company:中国平安
*
* @Project HIMS-FWA
* @date 2014年11月13日 上午10:39:31
* @version V1.0
*/
;
(function(){
	'use strict';

	var app = angular.module('fwa.mainApp');
	app.service('SelfFeedbackService',['$http','Modal','BaseURL',
	                  function($http,Modal,baseUrl){
		var debug = false,
		serv = this,
		debugUrls = {
				getSelfFeedback:baseUrl + 'mock/hcpms/warning/getSelfFeedback.json',
				getSelfFeedbackEdit: baseUrl + 'hcpmsWarning/getSelfFeedBackNotice.do',				
				//getSelfFeedbackEdit: baseUrl + 'mock/hcpms/warning/getSelfFeedbackEdit.json',
				saveSelfFeedback: baseUrl + 'hcpmsWarning/saveSelfFeedBack.do',
				//getSelfFeedbackDetail: baseUrl + 'mock/hcpms/warning/getSelfFeedbackDetail.json'
				getSelfFeedbackDetail: baseUrl + 'hcpmsWarning/getSelfFeedBackList.do'
			},
			urls = {
				getSelfFeedback:baseUrl + 'warnfeedback/findWarningFeedbackList.do',//医院反馈列表查询
				getSelfFeedbackEdit: baseUrl + 'hcpmsWarning/getSelfFeedBackNotice.do',//自查通知书
				saveSelfFeedback: baseUrl + 'hcpmsWarning/saveSelfFeedBack.do',//反馈保存
				getSelfFeedbackDetail: baseUrl + 'hcpmsWarning/getSelfFeedBackList.do',//反馈查看
				getSelfFeedbackWarn: baseUrl + 'hcpmsWarning/getSelfFeedBackWarn.do',     //预警提醒查看
				getSelfFeedBackWarnCheck: baseUrl + 'hcpmsWarning/getSelfFeedBackWarnCheck.do' //预警提醒确认
			};
		function getUrl(name) {
			if(debug) {
				return debugUrls[name];
			} else {
				return urls[name];
			}
		}
		
		serv.loading = false;

		serv.setPriodDate = function(start,end){
			var date="";
			var reg=new RegExp("-","g");
			if(start){
				date=date+start.replace(reg,"");
			}
			date+=' - ';
			if(end){
				date=date+end.replace(reg,"");
			}
			return date;
		}
		
		/**获取医院所有自查列表**/
		serv.getSelfFeedback = function(jsonObj){
              return $http({
                  url:getUrl('getSelfFeedback'),
                  method:'GET',
                  params:jsonObj
              });
        };
		
		
		/**获取医院自查基本信息**/
		serv.getSelfFeedbackEdit = function(jsonObj){
              return $http({
                  url:getUrl('getSelfFeedbackEdit'),
                  method:'GET',
                  params:jsonObj
              });
        };
        
		/**获取反馈节点列表**/
        serv.getfeedbackstatus = function(){
      	  if(!serv.actinstList){
				$http({
			    	 method: "get",
			    	 url:baseUrl+'warnfeedback/getfeedbackstatus.do'
				}).success(function(response, status, headers, config){
					serv.actinstList = response.result;
				});
			}
        };
        
		/**获取反馈处理方式列表**/
        serv.getfeedbackprocess = function(){
      	  if(!serv.actinstList){
				$http({
			    	 method: "get",
			    	 url:baseUrl+'warnfeedback/getfeedbackprocess.do'
				}).success(function(response, status, headers, config){
					serv.processList = response.result;
				});
			}
        };

        
        /**
         * 根据医院编码获取所属科室
         */
        serv.getMedicalDeptInfoList = function(orgCode){
        	return $http({
		    	 method: "get",
		    	 url: baseUrl+'community/getMedicalDeptInfoList.do',
		    	 params:{
		    		 orgCode:orgCode
		    	 }
			});
        }
        
        /**
         * 提交医院自查反馈信息
         */
        serv.saveSelfFeedback = function(jsonObj){
        	return $http.post(getUrl('saveSelfFeedback'),jsonObj);
        }
        
        /**查看医院自查详细信息**/
		serv.getSelfFeedbackDetail = function(jsonObj){
              return $http({
                  url:getUrl('getSelfFeedbackDetail'),
                  method:'GET',
                  params:jsonObj
              });
        };
        
        /**
         * 医院预警提醒查看
         */
        serv.getSelfFeedbackWarn = function(jsonObj){
        	return $http({
                url:getUrl('getSelfFeedbackWarn'),
                method:'GET',
                params:jsonObj
            });        	
        }
        
        /**
         * 医院预警提醒确认
         */
        serv.getSelfFeedBackWarnCheck = function(jsonObj){
        	return $http({
                url:getUrl('getSelfFeedBackWarnCheck'),
                method:'GET',
                params:jsonObj
            });        	
        }
        
        
        
        /**
         * 预警反馈--查询附件信息
         */
        this.showImage = function(jsonObj,callback){
            return $http({
                url:baseUrl + 'common/getFileInfo.do',
                method:'GET',
                params:jsonObj
            });
        };
        
        
        
        

	}]);
	
})();